/*
 * Editar.java
 *
 * Created on 1 de febrero de 2009, 18:01
 */

package not.visual;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 *En este JDialog se modifican o se eliminan las notas
 * @author  Guille
 */
public class Editar extends javax.swing.JDialog {
    Locale l = Locale.getDefault();
  ResourceBundle rs = ResourceBundle.getBundle("org.i18n.messages",l);
    /**
     * Este String protegido contiene el titulo cambiado
     */

protected String tituloFinal;
/**
 * Este String protegido contiene el texto cambiado
 */
protected String textoFinal;
/**
 * Este integer protegido contiene el valor del comando solicitado
 */
protected int accion = 0;
/**
 * Este valor se le pasa al integer accion para representar el comando modificar
 */
public static int MODIFICADO = 1;
/**
 * Este valor se le pasa al integer accion para representar el comando borrar
 */
public static int BORRADO = 2;
/**
 * Este valor se le pasa al integer accion para representar el comando cancelar
 */
public static int DESCARTADO = 0;
    /** Se crea la clase Editar, ademas de los 2 parametros clasicos de los
     JDialog, se le pasa una Nota*/
    public Editar(java.awt.Frame parent, boolean modal,not.beans.Nota n) {
        super(parent, modal);
        initComponents();
        titulo.setText(n.getTitulo());
        texto.setText(n.getTexto());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jlTitulo = new javax.swing.JLabel();
        jlTexto = new javax.swing.JLabel();
        titulo = new javax.swing.JTextField();
        texto = new javax.swing.JTextField();
        guardarCambios = new javax.swing.JButton();
        descartarCambios = new javax.swing.JButton();
        eliminarNota = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(rs.getString("note.edit.form.title"));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setText(rs.getString("note.edit.form.title"));

        jlTitulo.setText(rs.getString("note.title"));

        jlTexto.setText(rs.getString("note.text"));

        titulo.setFont(new java.awt.Font("Tahoma", 1, 14));
        titulo.setForeground(new java.awt.Color(0, 102, 255));

        texto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textoActionPerformed(evt);
            }
        });

        guardarCambios.setText(rs.getString("note.edit.options.save"));
        guardarCambios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                guardarCambiosActionPerformed(evt);
            }
        });

        descartarCambios.setText(rs.getString("note.edit.options.discard"));
        descartarCambios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                descartarCambiosActionPerformed(evt);
            }
        });

        eliminarNota.setText(rs.getString("note.edit.options.delete"));
        eliminarNota.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                eliminarNotaActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jlTexto)
                            .addComponent(jlTitulo))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(texto, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
                            .addComponent(titulo, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(guardarCambios)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(descartarCambios)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(eliminarNota)))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(154, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(132, 132, 132))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlTitulo)
                    .addComponent(titulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(40, 40, 40)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlTexto)
                    .addComponent(texto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(guardarCambios)
                    .addComponent(descartarCambios)
                    .addComponent(eliminarNota))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void textoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textoActionPerformed

}//GEN-LAST:event_textoActionPerformed

private void eliminarNotaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_eliminarNotaActionPerformed
accion = this.BORRADO;
this.dispose();
}//GEN-LAST:event_eliminarNotaActionPerformed

private void guardarCambiosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_guardarCambiosActionPerformed
// TODO add your handling code here
    tituloFinal = titulo.getText();
    textoFinal = texto.getText();
    accion = this.MODIFICADO;
    this.dispose();
}//GEN-LAST:event_guardarCambiosActionPerformed

private void descartarCambiosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_descartarCambiosActionPerformed
// TODO add your handling code here:
    accion = this.DESCARTADO;
    this.dispose();
}//GEN-LAST:event_descartarCambiosActionPerformed

    /**
    * @param args the command line arguments
    */
   

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton descartarCambios;
    private javax.swing.JButton eliminarNota;
    private javax.swing.JButton guardarCambios;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jlTexto;
    private javax.swing.JLabel jlTitulo;
    private javax.swing.JTextField texto;
    private javax.swing.JTextField titulo;
    // End of variables declaration//GEN-END:variables

}
